local skel = fk.CreateSkill {
  name = "emo__jiaozong",
}

Fk:loadTranslationTable{
  ["emo__jiaozong"] = "骄纵",
  [":emo__jiaozong"] = "当你使【杀】指定其他角色后，你可以弃置一张牌，令该角色交给你一张类型相同的牌，否则其不能响应；当你成为其他角色【杀】目标后，你可以弃置一张牌，令该角色交给你一张类型相同的牌，否则此【杀】对你无效。",

  ["#emo__jiaozong-off-cost"] = "骄纵：你可以弃置一张牌，令 %src 交给你一张类型相同的牌，否则其不能响应",
  ["#emo__jiaozong-off-give"] = "骄纵：你需给 %src 一张%arg牌，否则不能响应【杀】",
  ["#emo__jiaozong-def-cost"] = "骄纵：你可以弃置一张牌，令 %src 交给你一张类型相同的牌，否则【杀】对你无效",
  ["#emo__jiaozong-def-give"] = "骄纵：你需给 %src 一张%arg牌，否则【杀】对其无效",
}

skel:addEffect(fk.TargetSpecified, {
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and data.card.trueName == "slash" and not player:isNude()
    and data.from ~= data.to
  end,
  on_cost = function (self, event, target, player, data)
    local cards = player.room:askToDiscard(player, {
      min_num = 1, max_num = 1, skill_name = skel.name, include_equip = true, cancelable = true,
      skip = true, prompt = "#emo__jiaozong-off-cost:" .. data.to.id,
    })
    if #cards > 0 then
      event:setCostData(self, {cards = cards})
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local cards = event:getCostData(self).cards
    if not cards then return end
    local other = data.to
    local t = Fk:getCardById(cards[1]):getTypeString()
    room:throwCard(cards, skel.name, player, player)
    if player.dead then return end
    local give = room:askToCards(other, {
      min_num = 1, max_num = 1, include_equip = true, cancelable = true, skill_name = skel.name,
      pattern = ".|.|.|.|.|"..t, prompt = "#emo__jiaozong-off-give:" .. player.id .. "::" .. t
    })
    if #give > 0 then
      room:obtainCard(player, give, false, fk.ReasonGive, other, skel.name)
    else
      data:setDisresponsive(other)
    end
  end,
})

skel:addEffect(fk.TargetConfirmed, {
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and data.card.trueName == "slash" and not player:isNude()
    and data.from ~= data.to
  end,
  on_cost = function (self, event, target, player, data)
    local cards = player.room:askToDiscard(player, {
      min_num = 1, max_num = 1, skill_name = skel.name, include_equip = true, cancelable = true,
      skip = true, prompt = "#emo__jiaozong-def-cost:" .. data.from.id,
    })
    if #cards > 0 then
      event:setCostData(self, {cards = cards})
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local cards = event:getCostData(self).cards
    if not cards then return end
    local other = data.from
    local t = Fk:getCardById(cards[1]):getTypeString()
    room:throwCard(cards, skel.name, player, player)
    if player.dead then return end
    local give = room:askToCards(other, {
      min_num = 1, max_num = 1, include_equip = true, cancelable = true, skill_name = skel.name,
      pattern = ".|.|.|.|.|"..t, prompt = "#emo__jiaozong-def-give:" .. player.id .. "::" .. t
    })
    if #give > 0 then
      room:obtainCard(player, give, false, fk.ReasonGive, other, skel.name)
    else
      data:setNullified(player)
    end
  end,
})

return skel
